
<style type="text/css">
    .layui-form-item .layui-form-label{width:130px;text-align:right;}
    .layui-form-item .layui-input-inline{max-width:80%;width:auto;min-width:260px;}
    .layui-form-mid code{color:#5FB878;}
</style>

<form action="{:url('?group='.input('param.group', 'base'))}" class="page-list-form layui-form" method="post">

    <!--图片-->
    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <div class="layui-input-inline upload">
            <button type="button" name="upload" class="layui-btn layui-btn-primary layui-upload" lay-type="image" >请上传</button>
            <input type="hidden" class="upload-input" name="" value="">
            <div id="mydiv"></div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"> </label>
        <div class="layui-input-block">
            <button type="submit" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="formSubmit">提交</button>
        </div>
    </div>
</form>

{include file="block/layui" /}
<script>
    layui.use(['jquery', 'laydate', 'upload'], function() {
        var $ = layui.jquery,
            laydate = layui.laydate,
            layer = layui.layer,
            upload = layui.upload;

        upload.render({
            elem: '.layui-upload',
            url: '{:url("system/annex/upload?thumb=no&water=no")}'
            ,method: 'post'
            ,before: function(input) {
                layer.msg('文件上传中...', {time:3000000});
            },done: function(res, index, upload) {
                var obj = this.item;
                if (res.code == 0) {
                    layer.msg(res.msg);
                    return false;
                }
                layer.closeAll();
                var input = $(obj).parents('.upload').find('.upload-input');
                if ($(obj).attr('lay-type') == 'image') {
                    //input.siblings('img').attr('src', res.data.file).show();
                    $("#mydiv").append("<img src='"+ res.data.file +"' style='display:inline-block;border-radius:5px;border:1px solid #ccc' width='36' height='36'>");
                }
                input.val(res.data.file);
            }
        });

        /* 绑定多个日期控件 */
        $('.layui-date').each(function(i) {
            var t = $(this), option = {
                elem: this,
                type: t.attr('laydate-type'),
                trigger: 'click'
            };

            laydate.render(option);
        });
    });
</script>